<template>
	<view>
		<view>
			<table-title content="白卡持有列表"></table-title>
			<view class="choice-bar">
				<view class="nav-choice" :class="isActive[index]" v-for="(value,index) in navChoice" :key="index"
					@click="changeActive(index)">{{value}}</view>
			</view>
			<application-record v-for="(item,index) in recordList" :key="index"
				:company="item.company" :building="item.building" :time="item.time"
				:goods="item.goods" :state="item.state" @getClick="toContractDetails"></application-record>
		</view>
		<u-tabbar v-model="current" :list="list" :before-switch="clickTabbar"></u-tabbar>
	</view>
</template>

<script>
	export default{
		data() {
			return {
				chooseState: '',
				navChoice: ['正使用','已过期'],
				isActive: ['active-choice-contract','nav-choice-contract'],
				activeIndex: 0,
				recordList:[
					{'company':'福建海峡科技有限公司','building':'中青大厦','time':'2021-09-01 12:11:11',
					'goods':'2张','state':'待受理'},
					{'company':'福建天源科技有限公司','building':'万福大厦','time':'2021-09-01 12:11:11',
					'goods':'1张','state':'待受理'},
					{'company':'赛尔科技有限公司','building':'万福花园','time':'2021-09-01 12:11:11',
					'goods':'3张','state':'待受理'}
				],
				list: [
					{
						iconPath: "home",
						selectedIconPath: "home-fill",
						text: '首页',
						customIcon: false,
					},
					{
						iconPath: "photo",
						selectedIconPath: "photo-fill",
						text: '楼层管家',
						customIcon: false,
					},
					{
						iconPath: "https://cdn.uviewui.com/uview/common/min_button.png",
						selectedIconPath: "https://cdn.uviewui.com/uview/common/min_button_select.png",
						text: '发现',
						customIcon: false,
					},
					{
						iconPath: "play-right",
						selectedIconPath: "play-right-fill",
						text: '消息',
						count: 23,
						customIcon: false,
					},
					{
						iconPath: "account",
						selectedIconPath: "account-fill",
						text: '我的',
					},
				],
				current: 0
			}
		},
		methods: {
			changeActive(e) {
				if(e!==this.activeIndex){
					let tmp = [...this.isActive]
					tmp[e] = 'active-choice-contract'
					tmp[this.activeIndex] = 'nav-choice-contract'
					this.activeIndex = e
					this.isActive = tmp
					this.choosedState = this.navChoice[this.activeIndex]
				}
				for(let i=0; i<this.recordList.length; i++){
					this.recordList[i].state = this.choosedState
				}
			},
			clickTabbar(index) {
				switch(index){
					case 0:
						console.log('首页')
						uni.redirectTo({
							url:'/pages/home/home'
						})
						return true
						break
					case 1:
						console.log('楼层管家')
						return true
						break
					case 2:
						console.log('发现')
						return true
						break
					case 3:
						console.log('消息')
						uni.redirectTo({
							url:'/pages/systemAnnoucement/list/list'
						})
						return true
						break
					case 4:
						console.log('我的')
						uni.navigateTo({
							url:'/pages/myPage/myPage'
						})
						return true
						break
				}
			},
			toContractDetails() {
				uni.navigateTo({
					url:'../details/details'
				})
			}
		},
	}
</script>

<style>
	page{
		background-color: #ffffff
	}
	.nav-choice-contract{
		height: 100rpx;
		width: 387rpx;
		display: flex;
		align-items: center;
		justify-content: center;
		font-size: 30rpx;
		border-bottom: solid 5rpx #F1F1F1;
	}
	.choice-bar{
		display: flex;
		flex-direction: row;
		align-items: center;
		justify-content:center;
		width: 750rpx;
		color: #808080;
	}
	.active-choice-contract{
		height: 100rpx;
		width: 387rpx;
		display: flex;
		align-items: center;
		justify-content: center;
		font-size: 30rpx;
		font-weight:600;
		color: #DD524D;
		border-bottom: solid 5rpx #DD524D;
	}
</style>
